#include<iostream>
#include<vector>
using namespace std;

const int N = 1010;
long long dp[N][N];
int n, m, q;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int x = 0;
            cin >> x;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + x - dp[i - 1][j - 1];
        }
    }
    int x1, y1, x2, y2;
    while (q--)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        int sum = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
        cout << sum << endl;
    }

    return 0;
}
